import type { Axios, AxiosResponse, ResponseType } from 'axios'
import axiosInstance from '@/utils/network/axios'
import { message } from '@/components/message/message'

export async function axg_getConfigFile(
    filename: string,
    responseType: ResponseType = 'text'
): Promise<any> {
    const response: AxiosResponse = await axiosInstance.get(`/home/config-file?name=${filename}`, {
        responseType: responseType
    })
    if (response.data) return response.data
}

export async function axp_editConfigFile(
    filename: string = 'vsftpd',
    value: string
): Promise<AxiosResponse> {
    const response: AxiosResponse = await axiosInstance.post(`/home/config-file?name=${filename}`, value)
    return response
}

export async function axd_resetConfigFile(filename: string = 'vsftpd'): Promise<boolean> {
    const result: AxiosResponse = await axiosInstance.delete(`/home/config-file?name=${filename}`)
    if (result.status === 200) return true
    else return false
}
